﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

namespace UI
{
    public class UILuckTextTemplate : MonoBehaviour
    {
        #region UI
        public GameObject actived;
        public GameObject inActived;
        public UILabel des;
        public UISprite littleIcon;
        #endregion

        public const string hushou = "UI_jiban_hushou_";
        public const string jian = "UI_jiban_jian_";
        public const string renwu = "UI_jiban_renwu_";
        public const string shipin = "UI_jiban_shipin_";
        public const string xianglian = "UI_jiban_xianglian_";
        public const string xiezi = "UI_jiban_xiezi_";
        public const string zhuangbei = "UI_jiban_zhuangbei_";

        public const string actived_str = "b";
        public const string inactived_str = "a";

        void Awake()
        {
        }

        void SetActive(bool isActived)
        {
            actived.SetActive(isActived);
            inActived.SetActive(!isActived);
            
        }
        public void Init(string luckId,bool actived)
        {
            SetActive(actived);
            des.text = CommonMethod.GetLuckDesTex(luckId, actived);

            var luck = Dict.DictDataManager.Instance.tableYuanDao.GetById(luckId);
            if(luck.type == 1 ||
                luck.type == 2 ||
                luck.type == 3 ||
                luck.type == 4)
            {
                string str = renwu + (actived ? actived_str : inactived_str);
                littleIcon.spriteName = str;
            }
            else if(luck.type == 5)
            {
                var equipId = luck.equip0;
                var equip = Dict.DictDataManager.Instance.tableEquipDao.GetById(equipId);
                if(equip.type == 1)//武器
                {
                    string str = jian + (actived ? actived_str : inactived_str);
                    littleIcon.spriteName = str;
                }
                else if(equip.type == 2)//衣服
                {
                    string str = zhuangbei + (actived ? actived_str : inactived_str);
                    littleIcon.spriteName = str;
                }
                else if(equip.type == 3)//护肩
                {
                    string str = hushou + (actived ? actived_str : inactived_str);
                    littleIcon.spriteName = str;
                }
                else if(equip.type == 4)//鞋子
                {
                    string str = xiezi + (actived ? actived_str : inactived_str);
                    littleIcon.spriteName = str;
                }
            }
            else if(luck.type == 6)
            {
                var treaId = luck.treaId0;
                var trea = Dict.DictDataManager.Instance.tableTreasureDao.GetById(treaId);
                if(trea.type == 1)//戒子
                {
                    string str = shipin + (actived ? actived_str : inactived_str);
                    littleIcon.spriteName = str;
                }
                else if(trea.type == 0)//项链
                {
                    string str = xianglian + (actived ? actived_str : inactived_str);
                    littleIcon.spriteName = str;
                }
            }
        }

       

    }
}